import Main from './views/Main.vue';

export const loginRouter = {
    path: '/login',
    name: 'login',
    meta: {
        title: 'Login - 登录'
    },
    component: resolve => {
        require(['./views/login/login.vue'], resolve);
    }
};

export const page404 = {
    path: '/*',
    name: 'error_404',
    meta: {
        title: '404-页面不存在'
    },
    component: resolve => {
        require(['./views/error_page/404.vue'], resolve);
    }
};

export const page401 = {
    path: '/401',
    meta: {
        title: '401-权限不足'
    },
    name: 'error_401',
    component: resolve => {
        require(['./views/error_page/401.vue'], resolve);
    }
};

export const page500 = {
    path: '/500',
    meta: {
        title: '500-服务端错误'
    },
    name: 'error_500',
    component: resolve => {
        require(['./views/error_page/500.vue'], resolve);
    }
};

export const otherRouter = {
    path: '/',
    name: 'otherRouter',
    redirect: '/home',
    component: Main,
    children: [
        // {
        //     path: 'home', title: '首页', name: 'home_index', component: resolve => {
        //     require(['./views/home/home.vue'], resolve);
        //     }
        // },
        // ./views/environment_monitor/env_monitor.vue
        {
            path: 'home', title: '环境监测中心', name: 'home_index',
            component: resolve => {
                require(['./views/environment_monitor/env_monitor.vue'], resolve);
            }
        },

        {
            path: 'ownspace', title: '个人中心', name: 'ownspace_index', component: resolve => {
            require(['./views/own-space/own-space.vue'], resolve);
        }
        },
        {
            path: 'message', title: '消息中心', name: 'message_index', component: resolve => {
            require(['./views/message/message.vue'], resolve);
        }
        }
    ]
};

export const preview = {
    path: '/preview',
    name: 'preview',
    component: resolve => {
        require(['./views/form/article-publish/preview.vue'], resolve);
    }
};

export const locking = {
    path: '/locking',
    name: 'locking',
    component: resolve => {
        require(['./views/main_components/locking-page.vue'], resolve);
    }
};

export const appRouter = [
    {
        // path: '/environment_monitor',
        // redirect: '/environment_monitor/index',
        // icon: 'key',
        // name: 'environment_monitor',
        // title: '环境监测中心',
        // component: Main,
        // children: [
        //     {
        //         path: 'index',
        //         title: '环境监测中心',
        //         name: 'em_index',
        //         component: resolve => {
        //             require(['./views/environment_monitor/env_monitor.vue'], resolve);
        //         }
        //     }
        // ]


        path: '/environment_monitor',
        redirect: 'home',
        icon: 'earth',
        name: 'environment_monitor',
        title: '环境监测中心',
        component: Main,
        children: [
            {
                path: 'home', title: '环境监测中心', name: 'home_index',
                component: resolve => {
                    require(['./views/environment_monitor/env_monitor.vue'], resolve);
                }
            },
        ]


    },
    {
        path: '/data_manage',
        icon: 'soup-can-outline',
        name: 'data_manage',
        title: '数据管理中心',
        component: Main,
        children: [
            {
                path: 'crop_data_manage',
                icon: 'leaf',
                title: '作物信息管理',
                name: 'crop_data_manage',
                component: resolve => {
                    require(['./views/data_manage/crop_data_manage/crop_data_manage.vue'], resolve);
                }
            },
            {
                path: 'growth_cycle',
                icon: 'loop',
                title: '作物生育周期',
                name: 'growth_cycle',
                access: 1,
                component: resolve => {
                    require(['./views/data_manage/growth_cycle/growth_cycle.vue'], resolve);
                }
            },
            {
                path: 'growth_cycle_detail',
                icon: 'ios-flower',
                title: '作物生育周期-编辑',
                access: 1,
                name: 'growth_cycle_detail',
                component: resolve => {
                    require(['./views/data_manage/growth_cycle/growth_cycle_detail.vue'], resolve);
                }
            },
            {
                path: 'recom_fert',
                icon: 'erlenmeyer-flask',
                title: '作物推荐施肥',
                access: 1,
                name: 'recom_fert',
                component: resolve => {
                    require(['./views/data_manage/recom_fert/recom_fert.vue'], resolve);
                }
            },
            {
                path: 'recom_fert_edit/:datas',
                // path: 'recom_fert_edit',
                icon: 'erlenmeyer-flask',
                title: '作物推荐施肥-编辑',
                name: 'recom_fert_edit',
                access: 1,
                component: resolve => {
                    require(['./views/data_manage/recom_fert/recom_fert_edit.vue'], resolve);
                }
            },
            {
                path: 'planting_scheme',
                icon: 'erlenmeyer-flask',
                title: '作物种植计划',
                access:-1,
                name: 'planting_scheme',
                component: resolve => {
                    require(['./views/data_manage/planting_scheme/planting_scheme.vue'], resolve);
                }
            },
            {
                path: 'env_data_manage',
                icon: 'thermometer',
                title: '环境监测信息管理',
                name: 'env_data_manage',
                component: resolve => {
                    require(['./views/data_manage/env_data_manage/env_data_manage.vue'], resolve);
                }
            },
            {
                path: 'fert_data_manage',
                icon: 'erlenmeyer-flask',
                title: '肥料信息管理',
                name: 'fert_data_manage',
                component: resolve => {
                    require(['./views/data_manage/fert_data_manage/fert_data_manage.vue'], resolve);
                }
            },
            {
                path: 'soil_data_manage',
                icon: 'beaker',
                title: '土壤信息管理',
                name: 'soil_data_manage',
                component: resolve => {
                    require(['./views/data_manage/soil_data_manage/soil_data_manage.vue'], resolve);
                }
            }
        ]
    },
    {
        path: '/production_plans',
        icon: 'clipboard',
        name: 'production_plans',
        title: '生产计划中心',
        component: Main,
        children: [
            {
                path: 'index',
                icon: 'leaf',
                title: '生产计划中心',
                name: 'production_plans',
                component: resolve => {
                    require(['./views/production_plans/production_plans.vue'], resolve);
                }
            }
        ]
    },
    {
        path: '/task_executing',
        icon: 'flag',
        name: 'task_executing',
        title: '任务执行中心',
        component: Main,
        // access: -1,
        children: [
            {
                path: 'index',
                icon: 'leaf',
                title: '任务执行中心',
                // access: -1,
                name: 'task_executing',
                component: resolve => {
                    require(['./views/task_executing/task_executing.vue'], resolve);
                }
            }
        ]
    },
    {
        path: '/user_manage',
        icon: 'person',
        name:'user_manage',
        title: '用户管理',
        redirect:'index',
        component:Main,
        children:[
            {
                path:'index',
                title:'用户管理',
                name:'user_manage',
                component:resolve=>{
                    require(['./views/user_manage/user_manage.vue'],resolve);
                }
            }
        ]

    },
    {
        path: '/edit_production_operation',
        name: 'edit_production_operation1',
        title: '生产操作规范',
        access: -1,
        component: Main,
        children: [
            {
                path: 'index',
                title: '生产操作规范',
                name: 'edit_production_operation',
                component: resolve => {
                    require(['./views/data_manage/crop_data_manage/edit_production_operation.vue'], resolve);
                }
            }
        ]
    },
    {
        path: '/plan_list',
        name: 'plan_list',
        title: '计划列表',
        component: Main,
        access: -1,
        children: [
            {
                path: 'index',
                title: '计划任务详情',
                name: 'plan_list',
                component: resolve => {
                    require(['./views/production_plans/plan_list.vue'], resolve);
                }
            }
        ]

    },
    {
        path: '/access',
        redirect: '/access/index',
        icon: 'key',
        name: 'access',
        title: '权限管理AAA',
        access:-1,
        component: Main,
        children: [
            {
                path: 'index', title: '权限管理', name: 'access_index', component: resolve => {
                require(['./views/access/access.vue'], resolve);
            }
            }
        ]
    },
    {
        path: '/access-test',
        icon: 'lock-combination',
        title: '权限测试页',
        name: 'accesstest',
        access: 0,
        component: Main,
        children: [
            {path: 'index', title: '权限测试页', name: 'accesstest_index'}
        ]
    },
    {
        path: '/component',
        icon: 'social-buffer',
        name: 'component',
        title: '组件BBB',
        access: -1,
        component: Main,
        children: [
            {
                path: 'text-editer',
                icon: 'compose',
                name: 'text-editer',
                title: '富文本编辑器',
                component: abc => {
                    require(['./views/my_components/text-editer/textEditer.vue'], abc);
                }
            },
            {
                path: 'md-editor',
                icon: 'pound',
                name: 'md-editor',
                title: 'Markdown编辑器',
                component: resolve => {
                    require(['./views/my_components/markdown-editor/markdown-editor.vue'], resolve);
                }
            },
            {
                path: 'draggable-list',
                icon: 'arrow-move',
                name: 'draggable-list',
                title: '可拖拽列表',
                component: abb => {
                    require(['./views/my_components/draggable-list/draggable-list.vue'], abb);
                }
            },
            {
                path: 'file-upload',
                icon: 'android-upload',
                name: 'file-upload',
                title: '文件上传',
                component: resolve => {
                    require(['./views/my_components/file-upload/file-upload.vue'], resolve);
                }
            },
            {
                path: 'count-to',
                icon: 'arrow-graph-up-right',
                name: 'count-to',
                title: '数字渐变',
                component: resolve => {
                    require(['./views/my_components/count-to/count-to.vue'], resolve);
                }
            }
        ]
    },
    {
        path: '/form',
        icon: 'android-checkbox',
        name: 'form',
        title: '表单编辑CC',
        access: -1,
        component: Main,
        children: [
            {
                path: 'artical-publish', title: '文章发布', name: 'articalpublish', icon: 'compose', component: resolve => {
                require(['./views/form/article-publish/article-publish.vue'], resolve);
            }
            },
            {
                path: 'workflow', title: '工作流', name: 'workflow', icon: 'arrow-swap', component: resolve => {
                require(['./views/form/work-flow/work-flow.vue'], resolve);
            }
            }

        ]
    },
    {
        path: '/tables',
        icon: 'ios-grid-view',
        name: 'tables',
        title: '表格',
        access: -1,
        component: Main,
        children: [
            {
                path: 'dragableTable',
                title: '可拖拽排序',
                name: 'dragableTable',
                icon: 'arrow-move',
                component: resolve => {
                    require(['./views/tables/dragable-table.vue'], resolve);
                }
            },
            {
                path: 'editableTable', title: '可编辑表格', name: 'editableTable', icon: 'edit', component: resolve => {
                require(['./views/tables/editable-table.vue'], resolve);
            }
            },
            {
                path: 'exportableTable',
                title: '表格导出数据',
                name: 'exportableTable',
                icon: 'code-download',
                component: resolve => {
                    require(['./views/tables/exportable-table.vue'], resolve);
                }
            },
            {
                path: 'table2image', title: '表格转图片', name: 'table2image', icon: 'images', component: resolve => {
                require(['./views/tables/table-to-image.vue'], resolve);
            }
            }
        ]
    },
    {
        path: '/error-page',
        icon: 'android-sad',
        title: '错误页面',
        name: 'errorpage',
        access:-1,
        component: Main,
        children: [
            {
                path: 'index', title: '错误页面', name: 'errorpage_index', component: resolve => {
                require(['./views/error_page/error-page.vue'], resolve);
            }
            }
        ]
    }
];

export const routers = [
    loginRouter,
    otherRouter,
    preview,
    locking,
    ...appRouter,
    page500,
    page401,
    page404
];
